package domain.entity;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.HashSet;

import domain.value.Ingredient;

public class Pizza implements Serializable
{
	// Static
	
	private static final long serialVersionUID = 1L;

	private static HashMap<String, Pizza> pizzas = new HashMap<String, Pizza>();
	
	static
	{
		new Pizza("Margaritha");
		new Pizza("Caprese");
		new Pizza("Funghi");
		new Pizza("Merquez");
		new Pizza("Hawaii");
		
		
	}
	
	public static Pizza getPizza(String name)
	{
		synchronized (pizzas)
		{
			return pizzas.get(name);
		}
	}
	
	public static Pizza removePizza(String name)
	{
		synchronized (pizzas)
		{
			return pizzas.remove(name);
		}
	}
	
	public static HashSet<Pizza> getPizzas()
	{
		synchronized (pizzas)
		{
			return new HashSet<Pizza>(pizzas.values());
		}
	}
	
	// Instance
	
	private String name;
	
	private BigInteger price;
	
	private int discountDay = 2; // Default none
	
	private HashSet<Ingredient> ingredients;
	
	public Pizza(String name)
	{
		this.name = name;
		
		synchronized (pizzas)
		{
			pizzas.put(name, this);
		}
	}
	
	public String getName()
	{
		return name;
	}
	
	public void setPrice(BigInteger price)
	{
		this.price = price;
	}
	
	public BigInteger getPrice()
	{
		return price;
	}
	
	public void setDiscountDay(int discountDay)
	{
		this.discountDay = discountDay;
	}
	
	public int getDiscountDay()
	{
		return discountDay;
	}
	
	public void setIngredients(HashSet<Ingredient> ingredients)
	{
		this.ingredients = ingredients;
	}
	
	public HashSet<Ingredient> getIngredients()
	{
		return ingredients;
	}
}
